package org.example.entity;

import lombok.Data;

import java.io.Serializable;

/**
 * @author TonySong
 * @date 2024/4/25 0025
 * @time 15:37
 */
@Data
public class R implements Serializable {

    private Integer code;
    private Boolean flag;
    private String message;
    private Object data;

    public static R ok(){
        R r= new R();
        r.setCode(200);
        r.setMessage("success");
        r.setFlag(true);
        return  r;
    }
    public static R success(Object obj){
        R r= new R();
        r.setCode(200);
        r.setMessage("success");
        r.setFlag(true);
        r.setData(obj);
        return  r;
    }

    public static R error(){
        R r= new R();
        r.setCode(300);
        r.setMessage("error");
        r.setFlag(false);
        return  r;
    }

    public static R err(String mesg){
        R r= new R();
        r.setCode(300);
        r.setMessage(mesg);
        r.setFlag(false);
        return  r;
    }
}
